package com.prs.crm.action.sale.flow;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.ui.PaginationSupport;

import com.prs.crm.action.FlowAction;
import com.prs.crm.annotation.Clew;
import com.prs.crm.context.AppContext;
import com.prs.crm.domain.sale.QuotationSheet;
import com.prs.crm.domain.sale.SalesContract;
import com.prs.crm.service.sale.QuotationSheetService;
import com.prs.crm.service.sale.SalesContractService;

public class SalesContractFlowAction extends FlowAction<QuotationSheet> {
	
	private SalesContract salesContract;
	private SalesContractService salesContractService;	
	private PaginationSupport pagination;
	
	
	@Action("listSalesContractFlow")
	public String listSalesContractFlow() {
		pagination = this.getPaginationHelper().prepare(pagination);
		pagination = this.getSalesContractService().listFlowTask(SalesContract.class, pagination, AppContext.getAccountContext().currentUser());
		return SUCCESS;
	}
	
	@Action("editSalesContractFlow")
	public String editSalesContractFlow() {
		this.displayEndNodes();		
		return SUCCESS;
	}
	
	@Clew(results={"success"})
	@Action(value="submitSalesContractFlow",results={@Result(name="success",type="redirect",location="listSalesContractFlow")})
	public String submitSalesContractFlow() {
		this.getSalesContractService().execute(this.getNode(), this.getDetail(), salesContract, AppContext.getAccountContext().currentUser());
		this.setPrompt("提交成功");
		return SUCCESS;
	}

	
	
	public SalesContract getSalesContract() {
		return salesContract;
	}

	public void setSalesContract(SalesContract salesContract) {
		this.salesContract = salesContract;
	}

	public SalesContractService getSalesContractService() {
		return salesContractService;
	}

	public void setSalesContractService(SalesContractService salesContractService) {
		this.salesContractService = salesContractService;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	
	
	
	
	
	
	

}
